home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / computerjanitor / plugins / langpack_manual_plugin.py < prev    next >
Encoding:
Python Source  |  2009-04-27  |  2.2 KB  |  66 lines

  1. # langpack_manual_plugin.py - mark langpacks to be manually installed
  2. # Copyright (C) 2009  Canonical, Ltd.
  3. #
  4. # This program is free software: you can redistribute it and/or modify
  5. # it under the terms of the GNU General Public License as published by
  6. # the Free Software Foundation, version 3 of the License.
  7. #
  8. # This program is distributed in the hope that it will be useful,
  9. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11. # GNU General Public License for more details.
  12. #
  13. # You should have received a copy of the GNU General Public License
  14. # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  15.  
  16.  
  17. import computerjanitor
  18. _ = computerjanitor.setup_gettext()
  19.  
  20. import logging
  21.  
  22. class ManualInstallCruft(computerjanitor.Cruft):
  23.  
  24.     def __init__(self, pkg):
  25.         self.pkg = pkg
  26.  
  27.     def get_prefix(self):
  28.         return "mark-manually-installed"
  29.         
  30.     def get_shortname(self):
  31.         return self.pkg.name
  32.  
  33.     def get_description(self):
  34.         return (_("%s needs to be marked as manually installed.") % 
  35.                 self.pkg.name)
  36.  
  37.     def cleanup(self):
  38.         self.pkg.markKeep()
  39.         self.pkg.markInstall()
  40.  
  41.  
  42. class MarkLangpacksManuallyInstalledPlugin(computerjanitor.Plugin):
  43.  
  44.     """Plugin to mark language packs as manually installed.
  45.     
  46.     This works around quirks in the hardy->intrepid upgrade.
  47.  
  48.     """
  49.  
  50.     def __init__(self):
  51.         self.condition = ["from_hardyPostDistUpgradeCache"]
  52.  
  53.     def get_cruft(self):
  54.         # language-support-* changed its dependencies from "recommends"
  55.         # to "suggests" for language-pack-* - this means that apt will
  56.         # think they are now auto-removalable if they got installed
  57.         # as a dep of language-support-* - we fix this here
  58.         cache = self.app.apt_cache
  59.         for pkg in cache:
  60.             if (pkg.name.startswith("language-pack-") and 
  61.                 not pkg.name.endswith("-base") and
  62.                 cache._depcache.IsAutoInstalled(pkg._pkg) and
  63.                 pkg.isInstalled):
  64.                 logging.debug("setting '%s' to manual installed" % pkg.name)
  65.                 yield ManualInstallCruft(pkg)
  66.